package main

import "fmt"

func main() {
	//var a uint16
	//a = 65521
	//fmt.Println("int16(uint16(65521)) = ", int16(a))

	temp := 10011
	t := float64(-1*(temp-10000)) * 0.1
	hum := 382
	h := float64(hum) * 0.1
	fmt.Printf("temp = %.2f ℃\n", t)
	fmt.Printf("hum = %.2f %%\n", h)

	//list := []uint16{16456, 62915, 50243, 52756}
	//b := make([]byte, 0)
	//for _, v := range list {
	//	b2 := tools.Uint16ToBytes(v, "big")
	//	b = append(b, b2[0:]...)
	//}
	//fmt.Println("b=", b)
	//fmt.Println("f1=", tools.ByteToFloat32(b[0:4], "big"))
	//fmt.Println("f2=", tools.ByteToFloat32(b[4:8], "big"))

	//data := "01030000000AC5CD"
	//b, _ := tools.HexStrToByteArray(data)
	//fmt.Println("byte: ", b)
	//request := b[0:6]
	//request = app.AppendCrc16(request)
	//fmt.Printf("%s: %X\n", tools.GetNow(), request)
	////fmt.Println("success")
	//addr := b[0:1]
	//funCode := b[1:2]
	//startAddr := b[2:4]
	//addrNum := b[4:6]
	//crc := b[6:8]
	//fmt.Printf("addr = %s\n", tools.ByteArrayToHexStr(addr))
	//fmt.Printf("funCode = %s\n", tools.ByteArrayToHexStr(funCode))
	//fmt.Printf("startAddr = %s | v = %d\n", tools.ByteArrayToHexStr(startAddr), tools.BytesToUint16(addrNum, "big"))
	//fmt.Printf("addrNum = %s\n", tools.ByteArrayToHexStr(addrNum))
	//fmt.Printf("crc = %s\n", tools.ByteArrayToHexStr(crc))
	//
	//n := tools.BytesToUint16(addrNum, "big")
	//
	//resp := make([]byte, 0)
	//resp = append(resp, addr...)
	//resp = append(resp, funCode...)
	//resp = append(resp, byte(2*n))
	//for i := 1; i <= int(n); i++ {
	//	resp = append(resp, 255)
	//}
	//resp = app.AppendCrc16(resp)
	//
	//fmt.Printf("-------\nresp = %s\n", tools.ByteArrayToHexStr(resp))

	//resp :=
	//str := "0203500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100E6012B28280000000000000000000000000000000000000000000000559F"
	//fmt.Println("str = ", len(str))
	//buffer, err := tools.HexStrToByteArray(str)
	//if err != nil {
	//	fmt.Printf("error %s\n", err.Error())
	//	return
	//}
	//fmt.Println("--- 温湿压一体 ---")
	//fmt.Println("通讯状态", buffer[54])
	//fmt.Println("温度", buffer[55:57], tools.BytesToUint16(buffer[55:57], "big"))
	//fmt.Println("湿度", buffer[57:59], tools.BytesToUint16(buffer[57:59], "big"))
	//fmt.Println("气压", buffer[59:61], tools.BytesToUint16(buffer[59:61], "big"))

	//now := tools.GetNow()
	//data := model.Equip1{}
	//data.PtgCommunicationStatus = 9
	//data.PtgPressure = 1920.108
	//data.CreateTime = &now
	//
	//err := model.DB.Model(&model.Equip1{}).Where("id = ?", 1).Select("*").Omit("id").Updates(&data).Error
	//if err != nil {
	//	fmt.Printf("SQL ERROR SaveData1 %s\n", err.Error())
	//}
	//fmt.Println("success")

	//str := "0000000F"
	//b, _ := tools.HexStrToByteArray(str)
	//n := tools.BytesToUint32(b, "small")
	//fmt.Println("uint32 = ", n)
}
